/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: Faculty of informatics, Burapha University 01
 * License Type: Purchased
 */
package cn.imvc.app.entities;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="orders")
public class Orders implements Serializable {
	public Orders() {
	}
	
	private int id;
	
	private cn.imvc.app.entities.Member member;
	
	private String code;
	
	private String payCode;
	
	private Byte payChannel;
	
	private java.util.Date payTime;
	
	private Integer goodsAmount;
	
	private Integer discountAmount;
	
	private Integer orderAmount;
	
	private Integer freightAmount;
	
	private Integer resultAmount;
	
	private Integer refundAmount = new Integer(0);
	
	private java.util.Date cancelTime;
	
	private java.util.Date refundTime;
	
	private java.util.Date finishTime;
	
	private Byte state = new Byte("10");
	
	private String address;
	
	private java.util.Date createdAt;
	
	private java.util.Date updatedAt;
	
	private String name;
	
	private String telephone;
	
	private String addressId;
	
	private java.util.Set goodsOrder = new java.util.HashSet();
	
	private java.util.Set storageOrder = new java.util.HashSet();
	
	private java.util.Set salesReturn = new java.util.HashSet();
	
	private java.util.Set voucher = new java.util.HashSet();
	
	public void setId(int value) {
		this.id = value;
	}
	
	@Column(name="id", nullable=false)	
	@Id	
	@GeneratedValue(generator="CN_IMVC_APP_ENTITIES_ORDERS_ID_GENERATOR")	
	@org.hibernate.annotations.GenericGenerator(name="CN_IMVC_APP_ENTITIES_ORDERS_ID_GENERATOR", strategy="identity")	
	public int getId() {
		return id;
	}
	
	@Transient	
	public int getORMID() {
		return getId();
	}
	
	/**
	 * 订单单号
	 */
	public void setCode(String value) {
		this.code = value;
	}
	
	/**
	 * 订单单号
	 */
	@Column(name="code", nullable=true, length=255)	
	public String getCode() {
		return code;
	}
	
	/**
	 * 支付单号
	 */
	public void setPayCode(String value) {
		this.payCode = value;
	}
	
	/**
	 * 支付单号
	 */
	@Column(name="payCode", nullable=true, length=255)	
	public String getPayCode() {
		return payCode;
	}
	
	/**
	 * 支付渠道
	 */
	public void setPayChannel(byte value) {
		setPayChannel(new Byte(value));
	}
	
	/**
	 * 支付渠道
	 */
	public void setPayChannel(Byte value) {
		this.payChannel = value;
	}
	
	/**
	 * 支付渠道
	 */
	@Column(name="payChannel", nullable=true)	
	public Byte getPayChannel() {
		return payChannel;
	}
	
	/**
	 * 支付时间
	 */
	public void setPayTime(java.util.Date value) {
		this.payTime = value;
	}
	
	/**
	 * 支付时间
	 */
	@Column(name="payTime", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getPayTime() {
		return payTime;
	}
	
	/**
	 * 商品金额
	 */
	public void setGoodsAmount(int value) {
		setGoodsAmount(new Integer(value));
	}
	
	/**
	 * 商品金额
	 */
	public void setGoodsAmount(Integer value) {
		this.goodsAmount = value;
	}
	
	/**
	 * 商品金额
	 */
	@Column(name="goodsAmount", nullable=true, length=10)	
	public Integer getGoodsAmount() {
		return goodsAmount;
	}
	
	/**
	 * 优惠金额
	 */
	public void setDiscountAmount(int value) {
		setDiscountAmount(new Integer(value));
	}
	
	/**
	 * 优惠金额
	 */
	public void setDiscountAmount(Integer value) {
		this.discountAmount = value;
	}
	
	/**
	 * 优惠金额
	 */
	@Column(name="discountAmount", nullable=true, length=10)	
	public Integer getDiscountAmount() {
		return discountAmount;
	}
	
	/**
	 * 订单金额
	 */
	public void setOrderAmount(int value) {
		setOrderAmount(new Integer(value));
	}
	
	/**
	 * 订单金额
	 */
	public void setOrderAmount(Integer value) {
		this.orderAmount = value;
	}
	
	/**
	 * 订单金额
	 */
	@Column(name="orderAmount", nullable=true, length=10)	
	public Integer getOrderAmount() {
		return orderAmount;
	}
	
	/**
	 * 运费金额
	 */
	public void setFreightAmount(int value) {
		setFreightAmount(new Integer(value));
	}
	
	/**
	 * 运费金额
	 */
	public void setFreightAmount(Integer value) {
		this.freightAmount = value;
	}
	
	/**
	 * 运费金额
	 */
	@Column(name="freightAmount", nullable=true, length=10)	
	public Integer getFreightAmount() {
		return freightAmount;
	}
	
	/**
	 * 应付金额
	 */
	public void setResultAmount(int value) {
		setResultAmount(new Integer(value));
	}
	
	/**
	 * 应付金额
	 */
	public void setResultAmount(Integer value) {
		this.resultAmount = value;
	}
	
	/**
	 * 应付金额
	 */
	@Column(name="resultAmount", nullable=true, length=10)	
	public Integer getResultAmount() {
		return resultAmount;
	}
	
	/**
	 * 退款金额
	 */
	public void setRefundAmount(int value) {
		setRefundAmount(new Integer(value));
	}
	
	/**
	 * 退款金额
	 */
	public void setRefundAmount(Integer value) {
		this.refundAmount = value;
	}
	
	/**
	 * 退款金额
	 */
	@Column(name="refundAmount", nullable=true, length=10)	
	public Integer getRefundAmount() {
		return refundAmount;
	}
	
	/**
	 * 取消时间
	 */
	public void setCancelTime(java.util.Date value) {
		this.cancelTime = value;
	}
	
	/**
	 * 取消时间
	 */
	@Column(name="cancelTime", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getCancelTime() {
		return cancelTime;
	}
	
	/**
	 * 退款时间
	 */
	public void setRefundTime(java.util.Date value) {
		this.refundTime = value;
	}
	
	/**
	 * 退款时间
	 */
	@Column(name="refundTime", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getRefundTime() {
		return refundTime;
	}
	
	/**
	 * 订单完成时间
	 */
	public void setFinishTime(java.util.Date value) {
		this.finishTime = value;
	}
	
	/**
	 * 订单完成时间
	 */
	@Column(name="finishTime", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getFinishTime() {
		return finishTime;
	}
	
	/**
	 * 订单状态 ：10创建订单、11用户取消订单、12系统取消订单、13管理员驳回订单、20付款中、21付款成功、22付款失败、30待发货、31已发货、32发货失败、40确认收货、41系统确认收货、50退货申请、51审核通过、52审核失败、53退货成功 54退货失败、60订单完成
	 */
	public void setState(byte value) {
		setState(new Byte(value));
	}
	
	/**
	 * 订单状态 ：10创建订单、11用户取消订单、12系统取消订单、13管理员驳回订单、20付款中、21付款成功、22付款失败、30待发货、31已发货、32发货失败、40确认收货、41系统确认收货、50退货申请、51审核通过、52审核失败、53退货成功 54退货失败、60订单完成
	 */
	public void setState(Byte value) {
		this.state = value;
	}
	
	/**
	 * 订单状态 ：10创建订单、11用户取消订单、12系统取消订单、13管理员驳回订单、20付款中、21付款成功、22付款失败、30待发货、31已发货、32发货失败、40确认收货、41系统确认收货、50退货申请、51审核通过、52审核失败、53退货成功 54退货失败、60订单完成
	 */
	@Column(name="state", nullable=true)	
	public Byte getState() {
		return state;
	}
	
	/**
	 * 收货地址
	 */
	public void setAddress(String value) {
		this.address = value;
	}
	
	/**
	 * 收货地址
	 */
	@Column(name="address", nullable=true, length=255)	
	public String getAddress() {
		return address;
	}
	
	/**
	 * 创建时间
	 */
	public void setCreatedAt(java.util.Date value) {
		this.createdAt = value;
	}
	
	/**
	 * 创建时间
	 */
	@Column(name="createdAt", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getCreatedAt() {
		return createdAt;
	}
	
	/**
	 * 更新时间
	 */
	public void setUpdatedAt(java.util.Date value) {
		this.updatedAt = value;
	}
	
	/**
	 * 更新时间
	 */
	@Column(name="updatedAt", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getUpdatedAt() {
		return updatedAt;
	}
	
	public void setName(String value) {
		this.name = value;
	}
	
	@Column(name="name", nullable=true, length=255)	
	public String getName() {
		return name;
	}
	
	public void setTelephone(String value) {
		this.telephone = value;
	}
	
	@Column(name="telephone", nullable=true, length=255)	
	public String getTelephone() {
		return telephone;
	}
	
	public void setAddressId(String value) {
		this.addressId = value;
	}
	
	@Column(name="addressId", nullable=true, length=255)	
	public String getAddressId() {
		return addressId;
	}
	
	public void setMember(cn.imvc.app.entities.Member value) {
		this.member = value;
	}
	
	@ManyToOne(targetEntity=cn.imvc.app.entities.Member.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="memberId", referencedColumnName="id", nullable=false) })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public cn.imvc.app.entities.Member getMember() {
		return member;
	}
	
	public void setGoodsOrder(java.util.Set value) {
		this.goodsOrder = value;
	}
	
	@OneToMany(mappedBy="order", targetEntity=cn.imvc.app.entities.GoodsOrder.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getGoodsOrder() {
		return goodsOrder;
	}
	
	
	public void setStorageOrder(java.util.Set value) {
		this.storageOrder = value;
	}
	
	@OneToMany(mappedBy="order", targetEntity=cn.imvc.app.entities.StorageOrder.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getStorageOrder() {
		return storageOrder;
	}
	
	
	public void setSalesReturn(java.util.Set value) {
		this.salesReturn = value;
	}
	
	@OneToMany(mappedBy="order", targetEntity=cn.imvc.app.entities.SalesReturn.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getSalesReturn() {
		return salesReturn;
	}
	
	
	public void setVoucher(java.util.Set value) {
		this.voucher = value;
	}
	
	@OneToMany(mappedBy="order", targetEntity=cn.imvc.app.entities.Voucher.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getVoucher() {
		return voucher;
	}
	
	
	public String toString() {
		return toString(false);
	}
	
	public String toString(boolean idOnly) {
		if (idOnly) {
			return String.valueOf(getId());
		}
		else {
			StringBuffer sb = new StringBuffer();
			sb.append("Orders[ ");
			sb.append("Id=").append(getId()).append(" ");
			if (getMember() != null)
				sb.append("Member.Persist_ID=").append(getMember().toString(true)).append(" ");
			else
				sb.append("Member=null ");
			sb.append("Code=").append(getCode()).append(" ");
			sb.append("PayCode=").append(getPayCode()).append(" ");
			sb.append("PayChannel=").append(getPayChannel()).append(" ");
			sb.append("PayTime=").append(getPayTime()).append(" ");
			sb.append("GoodsAmount=").append(getGoodsAmount()).append(" ");
			sb.append("DiscountAmount=").append(getDiscountAmount()).append(" ");
			sb.append("OrderAmount=").append(getOrderAmount()).append(" ");
			sb.append("FreightAmount=").append(getFreightAmount()).append(" ");
			sb.append("ResultAmount=").append(getResultAmount()).append(" ");
			sb.append("RefundAmount=").append(getRefundAmount()).append(" ");
			sb.append("CancelTime=").append(getCancelTime()).append(" ");
			sb.append("RefundTime=").append(getRefundTime()).append(" ");
			sb.append("FinishTime=").append(getFinishTime()).append(" ");
			sb.append("State=").append(getState()).append(" ");
			sb.append("Address=").append(getAddress()).append(" ");
			sb.append("CreatedAt=").append(getCreatedAt()).append(" ");
			sb.append("UpdatedAt=").append(getUpdatedAt()).append(" ");
			sb.append("Name=").append(getName()).append(" ");
			sb.append("Telephone=").append(getTelephone()).append(" ");
			sb.append("AddressId=").append(getAddressId()).append(" ");
			sb.append("GoodsOrder.size=").append(getGoodsOrder().size()).append(" ");
			sb.append("StorageOrder.size=").append(getStorageOrder().size()).append(" ");
			sb.append("SalesReturn.size=").append(getSalesReturn().size()).append(" ");
			sb.append("Voucher.size=").append(getVoucher().size()).append(" ");
			sb.append("]");
			return sb.toString();
		}
	}
	
}
